/*
 * Alvin Baldemeca
 * TCSS 305 - Spring 2012
 * Assignment 4 Power Paint
 */

package gui.actions.paint;



import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;

import view.container.TetrisPaintPanel;


/**
 * Creats a Grid action to draw a grild to the panel.
 * @author Alvin Baldemeca
 * @version 5/17/2012
 *
 */
@SuppressWarnings("serial")
public class ShowPanelAction extends AbstractAction
{
  /**
   * The panel to perform the action to.
   */  
  private final TetrisPaintPanel my_panel;
  
  /**
   * The color to set the background to.
   */
  private final Color my_color;
   
  /**
   * Creates a grid action to draw grid lines on the panel.
   * @param the_panel the panel to show.
   * @param the_color the color to set the paint panel's background color to. 
   */
  public ShowPanelAction(final TetrisPaintPanel the_panel, final Color the_color)
  {
    super("Show Canvas");
    putValue(Action.MNEMONIC_KEY, KeyEvent.VK_C);
    putValue(Action.SELECTED_KEY, false);
    my_panel = the_panel;
    my_color = the_color;
  }

  @Override
  public void actionPerformed(final ActionEvent the_event)
  {
    if ((Boolean) getValue(Action.SELECTED_KEY))
    {
      my_panel.setOpaque(true);
      my_panel.setBackground(my_color);
    }
    else
    {
      my_panel.setOpaque(false);
      my_panel.setBackground(my_color);
    }
  }

}